﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Pap.Data;
using Pap.Web.Utils;

namespace Pap.Web.Modules.Reports.ViewModel
{
    /// <summary>
    /// 
    /// </summary>
    public class SystemOverallReportViewModel : IViewModel
    {
        /// <summary>
        /// 
        /// </summary>
        IReportRepository _ReportRepository;

        /// <summary>
        /// Initializes a new instance of the <see cref="SystemOverallReportViewModel"/> class.
        /// </summary>
        /// <param name="repo">The repo.</param>
        public SystemOverallReportViewModel(IReportRepository repo)
        {
            _ReportRepository = repo;
        }

        /// <summary>
        /// Systems the overall.
        /// </summary>
        /// <param name="Param">The param.</param>
        /// <returns></returns>
        public IEnumerable SystemOverall(SystemOverallParameters Param)
        {
            return _ReportRepository.SystemOverall(Param);
        }

        /// <summary>
        /// Gets all projects.
        /// </summary>
        /// <returns></returns>
        public IEnumerable<IProject> GetAllProjects()
        {
            return _ReportRepository.FindProjects(project => true);
        }

        /// <summary>
        /// Gets all committee.
        /// </summary>
        /// <returns></returns>
        public IEnumerable<ICommittee> GetAllCommittee()
        {
            return _ReportRepository.FindCommittee(committee => true);
        }

        /// <summary>
        /// Gets all project stage.
        /// </summary>
        /// <returns></returns>
        public IEnumerable<IProjectStage> GetAllProjectStage()
        {
            return _ReportRepository.FindProjectStage(projectstage => true);
        }


        /// <summary>
        /// Gets all responsibles.
        /// </summary>
        /// <returns></returns>
        public IEnumerable GetAllResponsibles()
        {
            var ResponsibleRoleID = new Guid("0cd962c7-2edd-0e22-3f84-73321d43f338");
            var Responsibles = _ReportRepository.FindUsers(user => user.UsersRoles.Select(userrole => userrole.RoleID).Contains(ResponsibleRoleID));

            return from user in Responsibles
                   select new
                   {
                       ResponsibleID = user.UserID,
                       ResponsibleName = user.DisplayName
                   };

        }

        /// <summary>
        /// Gets all social statuses.
        /// </summary>
        /// <returns></returns>
        public IEnumerable<ILookUpEntity> GetAllSocialStatuses()
        {
            return _ReportRepository.FindSocialStatuses(s => true);
        }

        /// <summary>
        /// Gets all educational levels.
        /// </summary>
        /// <returns></returns>
        public IEnumerable<ILookUpEntity> GetAllEducationalLevels()
        {
            return _ReportRepository.FindEducationalLevels(e => true);
        }

        /// <summary>
        /// Gets all loan types.
        /// </summary>
        /// <returns></returns>
        public IEnumerable<ILookUpEntity> GetAllLoanTypes()
        {
            return _ReportRepository.FindLoanTypes(lt => true);
        }

        /// <summary>
        /// Gets all loan places.
        /// </summary>
        /// <returns></returns>
        public IEnumerable<ILookUpEntity> GetAllLoanPlaces()
        {
            return _ReportRepository.FindLoanPlaces(lp => true);
        }


    }
}